/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package strategies;

import wrappers.EmployeeWrap;

/**
 *
 * @author KAV
 */
public class EmployeesEditRowStrategy extends EditRowStrategy {

    @Override
    protected void editRow() {
        date = pp.getParam("edit_year") + "-" + pp.getParam("edit_month") + "-" + pp.getParam("edit_day");
        isValid = pp.getParam("edit_name").matches("[a-zA-Zа-яА-Я 0-9-]+") && pp.getParam("edit_surname").matches("[a-zA-Zа-яА-Я 0-9-]+") && pp.getParam("edit_job").matches("[a-zA-Zа-яА-Я 0-9-]+") && !date.isEmpty() && (Integer.parseInt(pp.getParam("edit_manager")) >= 0) && (Integer.parseInt(pp.getParam("edit_salary")) != 0) && (Integer.parseInt(pp.getParam("edit_department")) != 0);
    }

    @Override
    protected Object createObject() {
        return new EmployeeWrap(Integer.parseInt(pp.getParam("edit_id")), pp.getParam("edit_name"), pp.getParam("edit_surname"), pp.getParam("edit_job"), Integer.parseInt(pp.getParam("edit_manager")), date, Integer.parseInt(pp.getParam("edit_salary")), Integer.parseInt(pp.getParam("edit_department")));
    }
}
